/**
 * 
 */
package com.cp16.tss.validation;

import java.awt.Color;

import com.cp16.tss.common.CommonMessage;
import com.cp16.tss.common.Constants;
import com.cp16.tss.form.UserLoginForm;

/**
 * @author GiangHN
 * @version 1.0
 * @since 01/01/2014
 * 
 */
public class UserLoginFormValidation {

	/**
	 * @param args
	 */
	public static boolean validateLoginForm(UserLoginForm userLoginForm) {
		Boolean flag = false;
		String userName = userLoginForm.getTxtUserName().getText();
		@SuppressWarnings("deprecation")
		String password = userLoginForm.getPwPassword().getText();
		if (userName.equals(Constants.BLANK)) {
			userLoginForm.getLblUserNameCheck().setText(CommonMessage.USERNAME_REQ);
			userLoginForm.getLblUserNameCheck().setForeground(Color.PINK);
			userLoginForm.getTxtUserName().setBackground(Color.PINK);
		} else {
			userLoginForm.getLblUserNameCheck().setText(Constants.BLANK);
			userLoginForm.getTxtUserName().setBackground(Color.WHITE);
			if (password.equals(Constants.BLANK)) {
				userLoginForm.getLblPasswordCheck().setText(CommonMessage.PASSWORD_REQ);
				userLoginForm.getLblPasswordCheck().setForeground(Color.PINK);
				userLoginForm.getPwPassword().setBackground(Color.PINK);
			} else {
				userLoginForm.getLblPasswordCheck().setText(Constants.BLANK);
				flag = true;
			}
		}
		return flag;
	}

}
